package com.liangwj.springbootquickstart.services;

import com.liangwj.springbootquickstart.MultiDataSource.DynamicDataSource;
import com.liangwj.springbootquickstart.MultiDataSource.DynamicDataSourceHolder;
import com.liangwj.springbootquickstart.annotation.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
@DataSource(value = "ds2")//自定义注解
public class DataSourceService {
    //TODO
    public void outputDataSource() {
        System.out.println("outputDataSource:" + DynamicDataSourceHolder.getThreadDataSource());
    }

    @DataSource(DataSource.DS2)
    public void outputDataSource1() {
        System.out.println("outputDataSource1:" + DynamicDataSourceHolder.getThreadDataSource());
    }

    @DataSource(value = "DS2")
    public void outputDataSource2() {
        System.out.println("outputDataSource2:" + DynamicDataSourceHolder.getThreadDataSource());
    }
}
